package com.yueqian.Utils;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * 数据连接工具类
 */
public class JDBCUtils {
 static    public Connection Connection(){
     Connection connection = null;
        //加载驱动1
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
        String url = "jdbc:mysql://localhost:3306/supermarket?useUnicode=true&characterEncoding=utf8";
        String user = "root";
        String password = "";
        //获取连接
         connection = DriverManager.getConnection(url, user, password);
        return connection;
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
}
